package com.mo.core.hessianProxyFactory;

import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.FactoryBean;

public class MoHessianProxyFactoryBean extends MoHessianClientInterceptor implements FactoryBean<Object> {
	private Object serviceProxy;
	
	public MoHessianProxyFactoryBean(String md5Key, String secret ,Long expiration){
		 this.setMd5Key(md5Key);
		 this.setSecret(secret);
		 this.setExpiration(expiration);
		 this.setOverloadEnabled(true);
	}

	@Override
	public void afterPropertiesSet() {
		super.afterPropertiesSet();
		this.serviceProxy = new ProxyFactory(getServiceInterface(), this).getProxy(getBeanClassLoader());
	}

	@Override
	public Object getObject() {
		return this.serviceProxy;
	}

	@Override
	public Class<?> getObjectType() {
		return getServiceInterface();
	}

	@Override
	public boolean isSingleton() {
		return true;
	}
}
